package inutan.game.business;

import inutan.common.inner.protocol.InnerPing;
import org.ricks.net.AioSession;
import org.ricks.net.handler.HeartPlugin;

import java.io.IOException;
import java.util.concurrent.TimeUnit;

public class InnerHeartPlugin extends HeartPlugin<Object> {

    public InnerHeartPlugin(int heartRate, int timeout, TimeUnit unit) {
        super(heartRate, timeout, unit);
    }

    public InnerHeartPlugin(int heartRate, int timeout, TimeUnit timeUnit, TimeoutCallback timeoutCallback) {
        super(heartRate, timeout, timeUnit, timeoutCallback);
    }

    /**
     * 这种方法是每秒自动写回client
     * @param session
     * @throws IOException
     */
    @Override
    public void sendHeartRequest(AioSession session) throws IOException {
//        session.sendResponse(Constant.PING);
    }

    @Override
    public boolean isHeartMessage(AioSession session, Object msg) {
        return msg instanceof InnerPing;
    }

}
